﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GN.Pay.TradeChannel.DefaultImpl
{
    /// <summary>
    /// 交易通道支付申请结果
    /// </summary>
    [Serializable]
    public class TradePayApplyResult : ITradePayApplyResult
    {
        public TradePayApplyResult(string payId, string payUrl,
            string payParam, TradePayApplyResultCallType callType, ITradeOrderQueryResult payResult = null)
        {
            this.PayId = payId;
            this.PayUrl = payUrl;
            this.PayParam = payParam;
            this.CallType = callType;
            if(callType == TradePayApplyResultCallType.PaySuccess)
            {
                if (payResult == null)
                {
                    throw new ArgumentNullException(nameof(payResult), "付款直接成功时，付款结果不能为 null");
                }
                PayResult = payResult;
            }
            else
            {
                PayResult = null;
            }            
        }
        /// <summary>
        /// 获取付款id
        /// </summary>
        public string PayId { get; private set; }

        /// <summary>
        /// 获取付款Url
        /// </summary>
        public string PayUrl { get; private set; }

        /// <summary>
        /// 获取付款参数
        /// </summary>
        public string PayParam { get; private set; }

        /// <summary>
        /// 获取调用类型
        /// </summary>
        public TradePayApplyResultCallType CallType { get; private set; }

        /// <summary>
        /// 付款结果
        /// </summary>
        public ITradeOrderQueryResult PayResult { get; private set; }
    }
}
